<template>
  <el-form
    label-position="top"
    :model="ruleForm"
    :rules="rules"
    ref="ruleForm"
    label-width="100px"
    class="demo-ruleForm"
  >
    <el-row>
      <el-col :span="5">
        <div class="grid-content bg-purple bg-purple-light">
          <el-form-item label="患者姓名" prop="name">
            <el-input
              v-model="ruleForm.name"
              placeholder="患者姓名/手机号码/证件号码/卡号"
            ></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="5"
        ><div class="grid-content bg-purple-light">
          <el-form-item label="患者卡号" prop="card">
            <el-input v-model="ruleForm.card"></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="5"
        ><div class="grid-content bg-purple bg-purple-light">
          <el-form-item label="患者年龄" prop="age">
            <el-input v-model="ruleForm.age"></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="5"
        ><div class="grid-content bg-purple-light">
          <el-form-item label="出生日期" required>
            <el-form-item prop="date">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                v-model="ruleForm.date"
              ></el-date-picker>
            </el-form-item>
          </el-form-item>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="5"
        ><div class="grid-content bg-purple-light">
          <el-form-item label="性别" prop="sex">
            <el-select v-model="ruleForm.sex" placeholder="请选择性别">
              <el-option label="男" value="shanghai"></el-option>
              <el-option label="女" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="5"
        ><div class="grid-content bg-purple-light">
          <el-form-item label="手机号码" prop="phone">
            <el-input v-model="ruleForm.phone"></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="5"
        ><div class="grid-content bg-purple-light">
          <el-form-item label="证件号码" prop="ID">
            <el-input v-model="ruleForm.ID"></el-input>
          </el-form-item>
        </div>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        name: "",
        card: "",
        age: "",
        date: "",
        sex: "",
        phone: "",
        ID: "",
      },
      rules: {
        name: [
          {
            required: true,
            message: "患者姓名/手机号码/证件号码/卡号",
            trigger: "blur",
          },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        card: [
          { required: true, message: "请输入患者卡号", trigger: "blur" },
          {
            min: 11,
            max: 13,
            message: "长度在 11 到 13 个字符",
            trigger: "blur",
          },
        ],
        age: [
          {
            required: true,
            message: "请输入患者年龄",
            trigger: "blur",
          },
        ],
        date: [
          {
            type: "date",
            required: true,
            message: "请输入出生日期",
            trigger: "change",
          },
        ],
        sex: [
          {
            required: true,
            message: "请输入性别",
            trigger: "blur",
          },
        ],
        phone: [
          {
            required: true,
            message: "请输入手机号码",
            trigger: "blur",
          },
          { min: 11, max: 11, message: "长度在11个字符", trigger: "blur" },
        ],
        ID: [
          {
            required: true,
            message: "请输入证件号码",
            trigger: "blur",
          },
          { min: 18, max: 18, message: "长度在18个字符", trigger: "blur" },
        ],
      },
    };
  },

};
</script>

<style lang="less" scoped>
.bg-purple-light {
  margin: 0 30px;
}
</style>
